/** layui-v0.0.7 跨设备模块化前端框架@LGPL www.layui.com By 贤心 */
;
layui.define(function(a) {
    "use strict";
    function t(a) {
        new p(a)
    }
    t.v = "1.3.0";
    var e = document,
    r = "getElementById",
    n = "getElementsByTagName",
    s = 0,
    p = function(a) {
        var t = this,
        e = t.config = a || {};
        e.item = s++,
        t.render(!0)
    };
    p.on = function(a, t, e) {
        return a.attachEvent ? a.attachEvent("on" + t,
        function() {
            e.call(a, window.even)
        }) : a.addEventListener(t, e, !1),
        p
    },
    p.prototype.type = function() {
        var a = this.config;
        return "object" == typeof a.cont ? void 0 === a.cont.length ? 2 : 3 : void 0
    },
    p.prototype.view = function() {
        var a = this,
        e = a.config,
        r = [],
        n = {};
        if (e.pages = 0 | e.pages, e.curr = 0 | e.curr || 1, e.groups = "groups" in e ? 0 | e.groups: 5, e.first = "first" in e ? e.first: "&#x9996;&#x9875;", e.last = "last" in e ? e.last: "&#x5C3E;&#x9875;", e.prev = "prev" in e ? e.prev: "&#x4E0A;&#x4E00;&#x9875;", e.next = "next" in e ? e.next: "&#x4E0B;&#x4E00;&#x9875;", e.pages <= 1) return "";
        for (e.groups > e.pages && (e.groups = e.pages), n.index = Math.ceil((e.curr + (e.groups > 1 && e.groups !== e.pages ? 1 : 0)) / (0 === e.groups ? 1 : e.groups)), e.curr > 1 && e.prev && r.push('<a href="javascript:;" class="layui-laypage-prev" data-page="' + (e.curr - 1) + '">' + e.prev + "</a>"), n.index > 1 && e.first && 0 !== e.groups && r.push('<a href="javascript:;" class="laypage_first" data-page="1"  title="&#x9996;&#x9875;">' + e.first + "</a><span>&#x2026;</span>"), n.poor = Math.floor((e.groups - 1) / 2), n.start = n.index > 1 ? e.curr - n.poor: 1, n.end = n.index > 1 ?
        function() {
            var a = e.curr + (e.groups - n.poor - 1);
            return a > e.pages ? e.pages: a
        } () : e.groups, n.end - n.start < e.groups - 1 && (n.start = n.end - e.groups + 1); n.start <= n.end; n.start++) n.start === e.curr ? r.push('<span class="layui-laypage-curr" ' + (/^#/.test(e.skin) ? 'style="background-color:' + e.skin + '"': "") + ">" + n.start + "</span>") : r.push('<a href="javascript:;" data-page="' + n.start + '">' + n.start + "</a>");
        return e.pages > e.groups && n.end < e.pages && e.last && 0 !== e.groups && r.push('<span>&#x2026;</span><a href="javascript:;" class="layui-laypage-last" title="&#x5C3E;&#x9875;"  data-page="' + e.pages + '">' + e.last + "</a>"),
        n.flow = !e.prev && 0 === e.groups,
        (e.curr !== e.pages && e.next || n.flow) && r.push(function() {
            return n.flow && e.curr === e.pages ? '<span class="layui-laypage-nomore" title="&#x5DF2;&#x6CA1;&#x6709;&#x66F4;&#x591A;">' + e.next + "</span>": '<a href="javascript:;" class="layui-laypage-next" data-page="' + (e.curr + 1) + '">' + e.next + "</a>"
        } ()),
        '<div name="laypage' + t.v + '" class="layui-laypage layui-laypage-' + (e.skin ?
        function(a) {
            return /^#/.test(a) ? "molv": a
        } (e.skin) : "default") + '" id="layui-laypage-' + a.config.item + '">' + r.join("") +
        function() {
            return e.skip ? '<span class="layui-laypage-total"><label>&#x5230;&#x7B2C;</label><input type="number" min="1" onkeyup="this.value=this.value.replace(/\\D/, \'\');" class="layui-laypage-skip"><label>&#x9875;</label><button type="button" class="layui-laypage-btn">&#x786e;&#x5b9a;</button></span>': ""
        } () + "</div>"
    },
    p.prototype.jump = function(a) {
        if (a) {
            for (var t = this,
            e = t.config,
            r = a.children,
            s = a[n]("button")[0], i = a[n]("input")[0], u = 0, o = r.length; o > u; u++)"a" === r[u].nodeName.toLowerCase() && p.on(r[u], "click",
            function() {
                var a = 0 | this.getAttribute("data-page");
                e.curr = a,
                t.render()
            });
            s && p.on(s, "click",
            function() {
                var a = 0 | i.value.replace(/\s|\D/g, "");
                a && a <= e.pages && (e.curr = a, t.render())
            })
        }
    },
    p.prototype.render = function(a) {
        var t = this,
        n = t.config,
        s = t.type(),
        p = t.view();
        2 === s ? n.cont.innerHTML = p: 3 === s ? n.cont.html(p) : e[r](n.cont).innerHTML = p,
        n.jump && n.jump(n, a),
        t.jump(e[r]("layui-laypage-" + n.item)),
        n.hash && !a && (location.hash = "!" + n.hash + "=" + n.curr)
    },
    a("laypage", t)
});